package com.kiln.juxingqs.utils;


import com.kiln.juxingqs.api.bean.BizContent;
import com.kiln.juxingqs.api.bean.PlaceOrderResult;

import org.json.JSONObject;


public class ConverterUtil {
    public static PlaceOrderResult JSONObject2placeOrderResult(JSONObject jsonObject) throws Exception{
        PlaceOrderResult placeOrderResult=new PlaceOrderResult();
        placeOrderResult.setTradeNo(jsonObject.getString("tradeNo"));
        placeOrderResult.setOutTradeNo(jsonObject.getString("outTradeNo"));
        placeOrderResult.setMerchantNo(jsonObject.getString("merchantNo"));
        placeOrderResult.setTradeAmt(jsonObject.getString("tradeAmt"));

        if(jsonObject.has("orderInfo")){
            placeOrderResult.setOrderInfo(jsonObject.getString("orderInfo"));

        }

            if(jsonObject.has("bizContent")){
            JSONObject biz=jsonObject.getJSONObject("bizContent");
            BizContent bizContent=new BizContent();
            bizContent.setAppId(biz.getString("appId"));
            bizContent.setNonceStr(biz.getString("nonceStr"));
            bizContent.setWxpackage(biz.getString("wxpackage"));
            bizContent.setPartnerId(biz.getString("partnerId"));
/*
            bizContent.setPayOrgCode(biz.getString("payOrgCode"));
*/
            bizContent.setPaySign(biz.getString("paySign"));
            bizContent.setPrepayId(biz.getString("prepayId"));
/*
            bizContent.setWcPrepayId(biz.getString("wcPrepayId"));
*/
            bizContent.setTimeStamp(biz.getString("timeStamp"));
            placeOrderResult.setBizContent(bizContent);
        }
        return placeOrderResult;
    }
}
